home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / GAS_1_38.ARJ / AS.H < prev    next >
C/C++ Source or Header  |  1990-10-11  |  9KB  |  293 lines

  1. /* as.h - global header file
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GAS, the GNU Assembler.
  5.  
  6. GAS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GAS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef asH
  21. #define asH            /* Don't declare things twice. */
  22.  
  23. #if !defined(__STDC__) && !defined(const)
  24. #define const /* ignore */
  25. #endif
  26.  
  27. #ifdef USG
  28. #define index strchr
  29. #define bzero(s,n) memset((s),0,(n))
  30. #define bcopy(from,to,n) memcpy((to),(from),(n))
  31. #define setbuffer(a,b,c)
  32. #endif
  33.  
  34. /*
  35.  * CAPITALISED names are #defined.
  36.  * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
  37.  * "lowercaseT" is a typedef of "lowercase" objects.
  38.  * "lowercaseP" is type "pointer to object of type 'lowercase'".
  39.  * "lowercaseS" is typedef struct ... lowercaseS.
  40.  *
  41.  * #define SUSPECT when debugging.
  42.  * #define DUMP to include data-structure dumpers.
  43.  * #define COMMON as "extern" for all modules except one, where you #define
  44.  *    COMMON as "".
  45.  * If TEST is #defined, then we are testing a module: #define COMMON as "".
  46.  */
  47.  
  48.  
  49.  
  50. /* These #defines are for parameters of entire assembler. */
  51.  
  52. /* #define SUSPECT JF remove for speed testing */
  53. /* #define DUMP */
  54. #define NDEBUG        /* JF disable asserts */
  55. /* These #includes are for type definitions etc. */
  56.  
  57. /* #include "style.h" */
  58. #include <stdio.h>
  59. #include <assert.h>
  60. #define obstack_chunk_alloc    xmalloc
  61. #define obstack_chunk_free    xfree
  62.  
  63. /* These defines are potentially useful */
  64. #define FALSE    (0)
  65. #define TRUE    (!FALSE)
  66. #define ASSERT    assert
  67. #define BAD_CASE(value)                            \
  68. {                                    \
  69.   as_fatal ("Case value %d unexpected at line %d of file \"%s\"\n",    \
  70.        value, __LINE__, __FILE__);                    \
  71. }
  72.  
  73.  
  74.  
  75.  
  76. /* These are assembler-wide concepts */
  77.  
  78.  
  79. #ifndef COMMON
  80. #ifdef TEST
  81. #define COMMON            /* declare our COMMONs storage here. */
  82. #else
  83. #define COMMON extern        /* our commons live elswhere */
  84. #endif
  85. #endif
  86.                 /* COMMON now defined */
  87.  
  88. #ifdef SUSPECT
  89. #define register        /* no registers: helps debugging */
  90. #define know(p) ASSERT(p)    /* know() is less ugly than #ifdef SUSPECT/ */
  91.                 /* assert()/#endif. */
  92. #else
  93. #define know(p)            /* know() checks are no-op.ed */
  94. #endif                /* #ifdef SUSPECT */
  95.  
  96.  
  97. char    *xmalloc();        /* keep C compilers happy */
  98. char    *xrealloc();        /* " */
  99. void    free();            /* " */
  100. #define xfree free
  101.  
  102. /* input_scrub.c */
  103.  
  104. /*
  105.  * Supplies sanitised buffers to read.c.
  106.  * Also understands printing line-number part of error messages.
  107.  */
  108.  
  109.                 /* Line number things. */
  110. int    seen_at_least_1_file();
  111. void    bump_line_counters();
  112. void    new_logical_line();
  113. void    as_where();
  114. void    as_perror();
  115. void    as_howmuch();
  116.                 /* Sanitising things. */
  117. void    input_scrub_begin();
  118. void    input_scrub_end();
  119. char    *input_scrub_new_file();
  120. char    *input_scrub_next_buffer();
  121.  
  122. /* subsegs.c     Sub-segments. Also, segment(=expression type)s.*/
  123.  
  124. /*
  125.  * This table describes the use of segments as EXPRESSION types.
  126.  *
  127.  *    X_seg    X_add_symbol  X_subtract_symbol    X_add_number
  128.  * SEG_NONE                        no (legal) expression
  129.  * SEG_PASS1                        no (defined) "
  130.  * SEG_BIG                    *    > 32 bits const.
  131.  * SEG_ABSOLUTE                         0
  132.  * SEG_DATA        *                 0
  133.  * SEG_TEXT        *            0
  134.  * SEG_BSS        *            0
  135.  * SEG_UNKNOWN        *            0
  136.  * SEG_DIFFERENCE    0        *    0
  137.  *
  138.  * The blank fields MUST be 0, and are nugatory.
  139.  * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
  140.  *
  141.  * SEG_BIG: X_add_number is < 0 if the result is in
  142.  *    generic_floating_point_number.  The value is -'c' where c is the
  143.  *    character that introduced the constant.  e.g. "0f6.9" will have  -'f'
  144.  *    as a X_add_number value.
  145.  *    X_add_number > 0 is a count of how many littlenums it took to
  146.  *    represent a bignum.
  147.  * SEG_DIFFERENCE:
  148.  * If segments of both symbols are known, they are the same segment.
  149.  * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
  150.  */
  151.  
  152. typedef enum
  153. {
  154.     SEG_ABSOLUTE,
  155.     SEG_TEXT,
  156.     SEG_DATA,
  157.     SEG_BSS,
  158.     SEG_UNKNOWN,
  159.     SEG_NONE,        /* Mythical Segment: NO expression seen. */
  160.     SEG_PASS1,        /* Mythical Segment: Need another pass. */
  161.     SEG_GOOF,        /* Only happens if AS has a logic error. */
  162.                 /* Invented so we don't crash printing */
  163.                 /* error message involving weird segment. */
  164.     SEG_BIG,            /* Bigger than 32 bits constant. */
  165.     SEG_DIFFERENCE        /* Mythical Segment: absolute difference. */
  166. }        segT;
  167. #define SEG_MAXIMUM_ORDINAL (SEG_DIFFERENCE)
  168.  
  169. typedef unsigned char    subsegT;
  170.  
  171. COMMON subsegT            now_subseg;
  172.                 /* What subseg we are accreting now? */
  173.  
  174.  
  175. COMMON segT            now_seg;
  176.                 /* Segment our instructions emit to. */
  177.                 /* Only OK values are SEG_TEXT or SEG_DATA. */
  178.  
  179.  
  180. extern char *const seg_name[];
  181. extern const int   seg_N_TYPE[];
  182. extern const segT  N_TYPE_seg[];
  183. void    subsegs_begin();
  184. void    subseg_change();
  185. void    subseg_new();
  186.  
  187. /* relax() */
  188.  
  189. typedef enum
  190. {
  191.     rs_fill,        /* Variable chars to be repeated fr_offset */
  192.                 /* times. Fr_symbol unused. */
  193.                 /* Used with fr_offset == 0 for a constant */
  194.                 /* length frag. */
  195.  
  196.     rs_align,        /* Align: Fr_offset: power of 2. */
  197.                 /* 1 variable char: fill character. */
  198.     rs_org,            /* Org: Fr_offset, fr_symbol: address. */
  199.                 /* 1 variable char: fill character. */
  200.  
  201.     rs_machine_dependent,
  202. #ifndef WORKING_DOT_WORD
  203.     rs_broken_word,        /* JF: gunpoint */
  204. #endif
  205. }
  206. relax_stateT;
  207.  
  208. /* typedef unsigned char relax_substateT; */
  209. /* JF this is more likely to leave the end of a struct frag on an align
  210.    boundry.  Be very careful with this.  */
  211. typedef unsigned long int relax_substateT;
  212.  
  213. typedef unsigned long int relax_addressT;/* Enough bits for address. */
  214.                 /* Still an integer type. */
  215.  
  216.  
  217. /* frags.c */
  218.  
  219. /*
  220.  * A code fragment (frag) is some known number of chars, followed by some
  221.  * unknown number of chars. Typically the unknown number of chars is an
  222.  * instruction address whose size is yet unknown. We always know the greatest
  223.  * possible size the unknown number of chars may become, and reserve that
  224.  * much room at the end of the frag.
  225.  * Once created, frags do not change address during assembly.
  226.  * We chain the frags in (a) forward-linked list(s). The object-file address
  227.  * of the 1st char of a frag is generally not known until after relax().
  228.  * Many things at assembly time describe an address by {object-file-address
  229.  * of a particular frag}+offset.
  230.  
  231.  BUG: it may be smarter to have a single pointer off to various different
  232. notes for different frag kinds. See how code pans out.
  233.  
  234.  
  235.  */
  236. struct frag            /* a code fragment */
  237. {
  238.     long unsigned int fr_address; /* Object file address. */
  239.     struct frag *fr_next;    /* Chain forward; ascending address order. */
  240.                 /* Rooted in frch_root. */
  241.  
  242.     long int fr_fix;    /* (Fixed) number of chars we know we have. */
  243.                 /* May be 0. */
  244.     long int fr_var;    /* (Variable) number of chars after above. */
  245.                 /* May be 0. */
  246.     struct symbol *fr_symbol; /* For variable-length tail. */
  247.     long int fr_offset;    /* For variable-length tail. */
  248.     char    *fr_opcode;    /*->opcode low addr byte,for relax()ation*/
  249.     relax_stateT fr_type;   /* What state is my tail in? */
  250.     relax_substateT    fr_subtype;
  251.         /* These are needed only on the NS32K machines */
  252.     char    fr_pcrel_adjust;
  253.     char    fr_bsr;
  254.     char    fr_literal [1];    /* Chars begin here. */
  255.                 /* One day we will compile fr_literal[0]. */
  256. };
  257. #define SIZEOF_STRUCT_FRAG \
  258.  ((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
  259.                 /* We want to say fr_literal[0] above. */
  260.  
  261. typedef struct frag fragS;
  262.  
  263. COMMON fragS *    frag_now;    /* -> current frag we are building. */
  264.                 /* This frag is incomplete. */
  265.                 /* It is, however, included in frchain_now. */
  266.                 /* Frag_now->fr_fix is bogus. Use: */
  267. /* Virtual frag_now->fr_fix==obstack_next_free(&frags)-frag_now->fr_literal.*/
  268.  
  269. COMMON fragS zero_address_frag;    /* For foreign-segment symbol fixups. */
  270. COMMON fragS  bss_address_frag;    /* For local common (N_BSS segment) fixups. */
  271.  
  272. void        frag_new();
  273. char *        frag_more();
  274. char *        frag_var();
  275. void        frag_wane();
  276. void        frag_align();
  277.  
  278.  
  279. /* main program "as.c" (command arguments etc) */
  280.  
  281. COMMON char
  282. flagseen[128];            /* ['x'] TRUE if "-x" seen. */
  283.  
  284. COMMON char *
  285. out_file_name;            /* name of emitted object file */
  286.  
  287. COMMON int    need_pass_2;    /* TRUE if we need a second pass. */
  288.  
  289.  
  290. #endif                /* #ifdef asH */
  291.  
  292. /* end: as.h */
  293.